import { Modal } from 'ant-design-vue';

export default function confirm(option) {
  option = option || {};

  const {
    title,
    icon,
    centered,
    closable,
    content,
    okText,
    okType,
    cancelText,
    className,
    cancelButtonProps,
    okButtonProps,
    zIndex,
    onOk
  } = option;

  const cancelBtnProps = cancelButtonProps || { props: {} };
  cancelBtnProps.props.prefixCls = 'tw-btn';

  const okBtnProps = okButtonProps || { props: {} };
  okBtnProps.props.prefixCls = 'tw-btn';

  Modal.confirm({
    prefixCls: 'tw-modal',
    title,
    icon: icon,
    class: className,
    centered: centered || true,
    closable,
    content,
    okText,
    okType,
    cancelText,
    cancelButtonProps: cancelBtnProps,
    okButtonProps: okBtnProps,
    zIndex: zIndex || 1000,
    onOk: () => {
      if (onOk) {
        onOk();
      }
    }
  });
}
